package power.game.sixtysix.entity;

import java.util.ArrayList;
import java.util.List;

public class Player {

	private List<Card> cardList;
	private ArrayList<Card> hand;
	private int cardSum = 0;
	
	public Player() {
		cardList = new ArrayList<Card>();
		hand = new ArrayList<Card>();
	}
	
	public void addCardToHand(Card card) {
		hand.add(card);
	}
	
	public Card removeCardFromHand(int card) {
		return hand.remove(card);
	}
	
	public Card[] getCardsFromHand() {
		Card[] cards = new Card[hand.size()];
		return hand.toArray(cards);
	}
	
	public void saveCards(Card card1, Card card2) {
		cardList.add(card1);
		cardList.add(card2);
		cardSum += card1.getCardValue().getValue() + card2.getCardValue().getValue();
	}
	
	public void addTwenty() {
		cardSum += 20;
	}
	
	public void addFourty() {
		cardSum += 40;
	}
	
	public int getCardSum() {
		return cardSum;
	}
	
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("\n Hand: ");
		for (Card card : hand) {
			sb.append(card);
			sb.append(";");
		}
		sb.append("\n Taken: ");
		for (Card card : cardList) {
			sb.append(card);
			sb.append(";");
		}
		sb.append("\n Sum: ");
		sb.append(cardSum);
		return sb.toString();
	}
}
